#include "choosemaptypedialog.h"
#include "stdafx.h"


ChooseMapTypeDialog::ChooseMapTypeDialog(QWidget *parent) :
    QDialog(parent),
    _index(1)
{
        QLabel * stubWarning = new QLabel(tr("This dialog is a stub!It doesn't work!"));
        QLabel * radioDescription = new QLabel(tr("Map generation type"));

        QRadioButton *radio1 = new QRadioButton("April random", this);
        QRadioButton *radio2 = new QRadioButton("MIdpoint displacement", this);

        radio1->setChecked(true);


        QPushButton * pcmdOk     = new QPushButton("&Ok");
        QPushButton * pcmdCancel = new QPushButton("&Cancel");

        connect(pcmdOk, SIGNAL(clicked()), SLOT(accept()));
        connect(pcmdCancel, SIGNAL(clicked()), SLOT(reject()));
        connect(radio1, SIGNAL(clicked()), SLOT(changeMapTypeToRandom()));
        connect(radio2, SIGNAL(clicked()), SLOT(changeMapTypeToMpdis()));

        //Layout setup
        ptopLayout = new QGridLayout;
        ptopLayout->addWidget(stubWarning,0,0);
        ptopLayout->addWidget(radioDescription,1,0);
        ptopLayout->addWidget(radio1,2,0);
        ptopLayout->addWidget(radio2,3,0);

        ptopLayout->addWidget(pcmdOk,4,0);
        ptopLayout->addWidget(pcmdCancel, 4, 1);
        setLayout(ptopLayout);
}

uint ChooseMapTypeDialog::getMapTypeId()
{
    return _index;
}

void ChooseMapTypeDialog::accept()
{
    _index = _tmpIndex;
    this->close();
}

void ChooseMapTypeDialog::changeMapTypeToRandom()
{
    _tmpIndex = 1;
}

void ChooseMapTypeDialog::changeMapTypeToMpdis()
{
    _tmpIndex = 2;
}
